package com.m1book.domain.book;

import java.io.Serializable;

import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

/**
 * 此类是对每个出版的书的体现，是个逻辑概念，而不是没本具体的书。每本具体的书的体现类是{@link ABook}。
 * 
 * @author Frankie
 *
 */
@Document(collection = "book")
public class Book implements Serializable {
	private static final long serialVersionUID = -4988620186788009001L;

	@Id
	private ObjectId id;
	
	@Indexed
	private String title;
	
	@Indexed
	private String author;
	
	@Indexed(unique = true)
	private String isbn10;
	
	@Indexed(unique = true)
	private String isbn13;
	
	@Field("info")
	private DoubanBookInfo douBanBookInfo;
	
	public Book() {
		id = ObjectId.get();
	}

	public ObjectId getId() {
		return id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getIsbn10() {
		return isbn10;
	}

	public void setIsbn10(String isbn10) {
		this.isbn10 = isbn10;
	}

	public String getIsbn13() {
		return isbn13;
	}

	public void setIsbn13(String isbn13) {
		this.isbn13 = isbn13;
	}
	
	public DoubanBookInfo getDoubanBookInfo() {
		return douBanBookInfo;
	}

	public void setDoubanBookInfo(DoubanBookInfo bookInfo) {
		this.douBanBookInfo = bookInfo;
	}
	
	@Override
	public String toString() {
		return "Book [title=" + title + ", author=" + author + ", isbn10="
				+ isbn10 + ", isbn13=" + isbn13 + "]";
	}
}
